package uk.ac.lkl.lpp.model;



import java.util.Map;

import uk.ac.lkl.lpp.model.PedagogyPlanModel;

import uk.ac.lkl.lpp.model.ldo.TeachingMethod;



public class TeachingMethodGroupSizeFieldGroup extends TeachingMethodFieldGroup {

    private Map<TeachingMethod, Integer> groupSizeMap;


    public TeachingMethodGroupSizeFieldGroup(PedagogyPlanModel model) {
        super(model);
        groupSizeMap = model.getMap("TeachingMethodGroupSize",
                                    TeachingMethod.class,
                                    Integer.class);
    }


    @Override
    protected Object getField(int listIndex,
                              TeachingMethod teachingMethod,
                              int fieldIndex) {
        return groupSizeMap.get(teachingMethod);
    }


    // need to notify listeners that has changed
    @Override
    protected void setField(TeachingMethod element,
                            int fieldIndex,
                            Object object) {
        Integer groupSize = (Integer) object;
        groupSizeMap.put(element, groupSize);
    }


    @Override
    public String getFieldName(int fieldIndex) {
        return "Group Size";
    }


    protected Class getClass(int fieldIndex) {
        return Integer.class;
    }


    @Override
    public int size() {
        return 1;
    }


    public boolean isEditable(TeachingMethod teachingMethod, int fieldIndex) {
        return true;
    }


    public boolean isPermanent() {
        return false;
    }


    public String getName() {
        return "Group Sizes";
    }


    public Object calculateTotal(int fieldIndex) {
        return null;
    }
}
